// 组合继承
function Parent(value) {
    this.val = value;
}
Parent.prototype.getValue = function(){
    console.log(this.val)
}
function Child(value){
    Parent.call(this,value)
}
Child.prototype = new Parent()

const child = new Child(1);

child.getValue()
child instanceof parent

// 寄生组合继承
function Parent1(value){
    this.val = value
}
Parent1.prototype.getValue = function (){
    console.log(this.val)
}
function Child1(value){
    Parent.call(this,value)
}
Child1.prototype = Object.create(Parent1.prototype,{
    constructor: {
        value: Child1,
        enumerable: false
    }
})
const child1 = new Child1(1)

// class继承
class Parent2 {
    constructor(value){
        this.val = value
    }
    getValue() {
        console.log(this.val)
    }
}
class Child2 extends Parent2 {
    constructor(value){
        super(value)
        this.val = value
    }
}
let child2 = new Child2(1)
child2.getValue()